package fr.ece.ing4.si.core;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class MonteCarloArgs {
    public EOptionFlag flag;
    public double S, X, T, r, b, v;
    public int nSteps, nSimulations;

    public void setArgsFromModel(int preloadedModel) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader("src\\fr\\ece\\ing4\\si\\core\\preloadedModels.txt"));

    String line = null;
    String[] data = null;
    for (int i = 0; i < preloadedModel; i++) {
        line = reader.readLine();
    }

    if (line != null) {
        data = line.split(",");
        if (data[0].equals("call")) {
            this.flag = EOptionFlag.call;
        } else if (data[0].equals("put")) {
            this.flag = EOptionFlag.put;
        }
        this.S = Double.parseDouble(data[1]);
        this.X = Double.parseDouble(data[2]);
        this.r = Double.parseDouble(data[3]);
        this.T = Double.parseDouble(data[4]);
        this.b = Double.parseDouble(data[5]);
        this.v = Double.parseDouble(data[6]);
        this.nSteps = Integer.parseInt(data[7]);
        this.nSimulations = Integer.parseInt(data[8]);
    }
}

}
